package com.ljh.product.controller;

import com.ljh.api.ProductApi;
import com.ljh.product.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ljh.api.model.ProductInfo;

/**
 * @author: Themberfue
 * @date: 2025/4/10 23:49
 * @description:
 */
@RequestMapping("/product")
@RestController
@Slf4j
public class ProductController implements ProductApi {
    @Autowired
    ProductService productService;

    @GetMapping("/{productId}")
    public ProductInfo getProductById(@PathVariable("productId") Integer productId) {
        log.info("接收的参数：{}", productId);
        return productService.getProductById(productId);
    }

    @RequestMapping("/p1")
    public String p1(Integer id) {
        return "product-service接收的参数：" + id;
    }

    @RequestMapping("/p2")
    public String p2(Integer id, String name) {
        return "product-service接收的参数：" + id + " " + name;
    }

    @RequestMapping("/p3")
    public String p3(ProductInfo productInfo) {
        return "product-service接收的参数：" + productInfo.toString();
    }

    @RequestMapping("/p4")
    public String p4(@RequestBody ProductInfo productInfo) {
        return "product-service接收的参数：" + productInfo.toString();
    }
}
